<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>C语言学习中心</title>
    <style>
        :root {
            --primary-color: #3498db;
            --secondary-color: #2980b9;
            --accent-color: #e74c3c;
            --light-color: #ecf0f1;
            --dark-color: #2c3e50;
            --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            --transition: all 0.3s ease;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        body {
            background-color: #f5f7fa;
            color: #333;
            line-height: 1.6;
        }
        
        header {
            background: linear-gradient(135deg, var(--primary-color), var(--dark-color));
            color: white;
            padding: 2rem 0;
            text-align: center;
            box-shadow: var(--shadow);
            margin-bottom: 2rem;
        }
        
        .header-content {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
        }
        
        h1 {
            font-size: 2.5rem;
            margin-bottom: 0.5rem;
        }
        
        .subtitle {
            font-size: 1.2rem;
            opacity: 0.9;
            max-width: 800px;
            margin: 0 auto;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
        }
        
        .course-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 25px;
            margin: 2rem 0;
        }
        
        .course-card {
            background: white;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: var(--shadow);
            transition: var(--transition);
            display: flex;
            flex-direction: column;
        }
        
        .course-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
        }
        
        .card-number {
            background: var(--primary-color);
            color: white;
            padding: 10px 15px;
            font-weight: bold;
            font-size: 1.1rem;
        }
        
        .card-content {
            padding: 20px;
            flex-grow: 1;
            display: flex;
            flex-direction: column;
        }
        
        .card-title {
            font-size: 1.3rem;
            margin-bottom: 10px;
            color: var(--dark-color);
        }
        
        .card-desc {
            color: #666;
            margin-bottom: 15px;
            flex-grow: 1;
        }
        
        .card-link {
            display: inline-block;
            background: var(--primary-color);
            color: white;
            padding: 8px 15px;
            border-radius: 5px;
            text-decoration: none;
            font-weight: 500;
            transition: var(--transition);
            align-self: flex-start;
        }
        
        .card-link:hover {
            background: var(--secondary-color);
        }
        
        footer {
            background: var(--dark-color);
            color: white;
            text-align: center;
            padding: 2rem 0;
            margin-top: 3rem;
        }
        
        .footer-content {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
        }
        
        @media (max-width: 768px) {
            .course-grid {
                grid-template-columns: 1fr;
            }
            
            h1 {
                font-size: 2rem;
            }
        }
    </style>
</head>
<body>
    <header>
        <div class="header-content">
            <h1>C语言编程学习中心</h1>
            <p class="subtitle">从基础到进阶，系统学习C语言编程。通过精心设计的课程体系，掌握计算机编程的核心概念。</p>
        </div>
    </header>
    
    <div class="container">
        <div class="course-grid">
            <!-- 课程卡片1 -->
            <div class="course-card">
                <div class="card-number">01</div>
                <div class="card-content">
                    <h3 class="card-title">C语言课程介绍</h3>
                    <p class="card-desc">了解C语言的历史、特点以及本课程的学习路线图。</p>
                    <a href="index.html" class="card-link">(就这一个不能点)</a>
                </div>
            </div>
            
            <!-- 课程卡片2 -->
            <div class="course-card">
                <div class="card-number">02</div>
                <div class="card-content">
                    <h3 class="card-title">C语言简介与环境搭建</h3>
                    <p class="card-desc">认识C语言的基本特性，并学习如何搭建开发环境。</p>
                    <a href="02-intro.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片3 -->
            <div class="course-card">
                <div class="card-number">03</div>
                <div class="card-content">
                    <h3 class="card-title">C程序结构</h3>
                    <p class="card-desc">掌握C语言程序的基本结构和组成部分。</p>
                    <a href="03-structure.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片4 -->
            <div class="course-card">
                <div class="card-number">04</div>
                <div class="card-content">
                    <h3 class="card-title">基本数据类型</h3>
                    <p class="card-desc">学习C语言中的各种基本数据类型及其使用。</p>
                    <a href="04-datatypes.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片5 -->
            <div class="course-card">
                <div class="card-number">05</div>
                <div class="card-content">
                    <h3 class="card-title">变量与常量</h3>
                    <p class="card-desc">理解变量和常量的概念、声明和使用方法。</p>
                    <a href="05-variables.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片6 -->
            <div class="course-card">
                <div class="card-number">06</div>
                <div class="card-content">
                    <h3 class="card-title">运算符</h3>
                    <p class="card-desc">掌握C语言中的各种运算符及其优先级。</p>
                    <a href="06-operators.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片7 -->
            <div class="course-card">
                <div class="card-number">07</div>
                <div class="card-content">
                    <h3 class="card-title">输入输出</h3>
                    <p class="card-desc">学习标准输入输出函数的使用方法。</p>
                    <a href="07-io.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片8 -->
            <div class="course-card">
                <div class="card-number">08</div>
                <div class="card-content">
                    <h3 class="card-title">条件语句</h3>
                    <p class="card-desc">掌握if、switch等条件控制结构。</p>
                    <a href="08-conditionals.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片9 -->
            <div class="course-card">
                <div class="card-number">09</div>
                <div class="card-content">
                    <h3 class="card-title">循环结构</h3>
                    <p class="card-desc">学习for、while、do-while等循环结构。</p>
                    <a href="09-loops.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片10 -->
            <div class="course-card">
                <div class="card-number">10</div>
                <div class="card-content">
                    <h3 class="card-title">函数基础</h3>
                    <p class="card-desc">理解函数的定义、声明和调用方法。</p>
                    <a href="10-functions.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片11 -->
            <div class="course-card">
                <div class="card-number">11</div>
                <div class="card-content">
                    <h3 class="card-title">作用域与存储类</h3>
                    <p class="card-desc">了解变量的作用域、生命周期和存储类别。</p>
                    <a href="11-scope.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片12 -->
            <div class="course-card">
                <div class="card-number">12</div>
                <div class="card-content">
                    <h3 class="card-title">递归函数</h3>
                    <p class="card-desc">掌握递归的概念和递归函数的编写方法。</p>
                    <a href="12-recursion.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片13 -->
            <div class="course-card">
                <div class="card-number">13</div>
                <div class="card-content">
                    <h3 class="card-title">一维数组</h3>
                    <p class="card-desc">学习一维数组的声明、初始化和使用方法。</p>
                    <a href="13-arrays.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片14 -->
            <div class="course-card">
                <div class="card-number">14</div>
                <div class="card-content">
                    <h3 class="card-title">多维数组</h3>
                    <p class="card-desc">掌握二维及以上多维数组的使用。</p>
                    <a href="14-multidim.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片15 -->
            <div class="course-card">
                <div class="card-number">15</div>
                <div class="card-content">
                    <h3 class="card-title">字符串处理</h3>
                    <p class="card-desc">学习字符串的表示和常用字符串处理函数。</p>
                    <a href="15-strings.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片16 -->
            <div class="course-card">
                <div class="card-number">16</div>
                <div class="card-content">
                    <h3 class="card-title">指针基础</h3>
                    <p class="card-desc">理解指针的概念和基本使用方法。</p>
                    <a href="16-pointers.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片17 -->
            <div class="course-card">
                <div class="card-number">17</div>
                <div class="card-content">
                    <h3 class="card-title">指针进阶</h3>
                    <p class="card-desc">深入学习指针的高级用法和技巧。</p>
                    <a href="17-pointers_advanced.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片18 -->
            <div class="course-card">
                <div class="card-number">18</div>
                <div class="card-content">
                    <h3 class="card-title">结构体</h3>
                    <p class="card-desc">掌握结构体的定义和使用方法。</p>
                    <a href="18-structs.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片19 -->
            <div class="course-card">
                <div class="card-number">19</div>
                <div class="card-content">
                    <h3 class="card-title">文件操作</h3>
                    <p class="card-desc">学习文件的打开、读写和关闭操作。</p>
                    <a href="19-files.html" class="card-link">开始学习</a>
                </div>
            </div>
            
            <!-- 课程卡片20 -->
            <div class="course-card">
                <div class="card-number">20</div>
                <div class="card-content">
                    <h3 class="card-title">综合项目</h3>
                    <p class="card-desc">运用所学知识完成一个完整的C语言项目。</p>
                    <a href="20-project.html" class="card-link">开始学习</a>
                </div>
            </div>
        </div>
    </div>
    
    <footer>
        <div class="footer-content">
            <p>© </p>
            <p>建议按顺序学习课程，逐步掌握C语言编程技能</p>
        </div>
    </footer>
</body>
</html>
<script>
    // 为所有卡片链接添加点击事件
    const cardLinks = document.querySelectorAll('.card-link');
    cardLinks.forEach(link => {
        link.addEventListener('click', async function (e) {
            e.preventDefault(); // 阻止默认链接行为
            const course = this.getAttribute('href').replace('.html', '');
             if (course == 'index') {
                return;
            }
            const fname = window.location.href.split('fname=')[1];
            try {
                const response = await fetch('/index/user/checkHtmlAuth', {
                    method: 'POST',
                    credentials: 'include', // 保持现有
                    headers: {
                        'Content-Type': 'application/json',
                        'Accept': 'application/json' // 添加Accept头
                    },
                    body: JSON.stringify({ name: course, fname: fname }),
                    mode: 'cors' // 明确指定CORS模式
                });
                const data = await response.json();
                if (data.code == 403) {
                    window.location.href = '/index/user/login';
                } else if (data.code === 1) {
                    if (course != 'index') {
                        window.location.href = `./${course}.html`;
                    }
                } else {
                    window.location.href = '/index/user/goumai';
                }
            } catch (error) {
                console.log(error);
            }
            //
        });
    });
</script>